package SingletonPattern;

/**
 * Created by HMF on 2021/06/15 11:35
 */
public class Main {
    public static void main(String[] args) {
        HungrySingleton singleton1 = HungrySingleton.getInstance();
        HungrySingleton singleton2 = HungrySingleton.getInstance();

        LazySingleton singleton3 = LazySingleton.getInstance();
        LazySingleton singleton4 = LazySingleton.getInstance();

        System.out.println(singleton1);
        System.out.println(singleton2);

        System.out.println(singleton3);
        System.out.println(singleton4);

        // 打印输出的对象是同一个
//        SingletonPattern.HungrySingleton@1b6d3586
//        SingletonPattern.HungrySingleton@1b6d3586

//        SingletonPattern.LazySingleton@4554617c
//        SingletonPattern.LazySingleton@4554617c
    }
}
